package com.darren.framework.Bean;


/**
 * ResponseBean 响应对象
 * @author 周金涛
 * @date 2019/10/13 16:39
 */
public class ResponseBean {

    /**
     * 响应状态回值码
     */
    private Integer code;

    /** 返回信息 */
    private String message;

    /** 返回的数据 */
    private Object data;

    public ResponseBean(Integer code, String message, Object data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    /**
     * 成功返回 不带数据
     */
    public static ResponseBean isOk(){
        return ResponseBean.isOk(null);
    }

    /**
     * 成功返回 带数据
     * @param data 数据
     */
    public static ResponseBean isOk(Object data){
        return new ResponseBean(ResponseCode.OK,"Ok",data);
    }

    /**
     * 警告
     * @param message
     * @return
     */
    public static ResponseBean isWarn(String message){
        return new ResponseBean(ResponseCode.WARN,message,null);
    }

    /**
     * 失败返回
     * @param message 错误信息
     */
    public static ResponseBean isError(String message){
        return new ResponseBean(ResponseCode.ERROR,message,null);
    }


    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }
}
